package question;

public class ReverseArray {
    public static void main(String[] args)
    {
        int[] arr = {4,1,3,5,9,2,1};
        reverse(arr);
        showArray(arr);
    }
    public static void reverse(int[] arr)
    {
        int i = 0,j = arr.length-1;
        int tmp;
        while(i!=j&&i<j) {
            tmp = arr[i];
            arr[i] = arr[j];
            arr[j] = tmp;
            ++i;
            --j;
        }
    }
    public static void showArray(int[] arr){
        for(int i=0; i<arr.length; i++)
            System.out.print(" "+arr[i]);
        System.out.println(" ");
    }
}
